$OpenBSD: patch-Scripts_sql-update-2_2_17_to_2_3_0_sh,v 1.2 2015/10/23 07:53:46 sebastia Exp $
--- Scripts/sql-update-2.2.17_to_2.3.0.sh.orig	Wed Sep 16 20:41:29 2015
+++ Scripts/sql-update-2.2.17_to_2.3.0.sh	Fri Oct 23 09:40:24 2015
@@ -1,4 +1,4 @@
-#!/bin/bash
+#!/bin/sh
 
 set -e 
 # This script only works with PostgreSQL
@@ -11,15 +11,19 @@ defaultusername=$USER
 defaulthostname=localhost
 defaultdatabase=$USER
 #indextable=sogo_folder_info
-indextable=$(sogo-tool dump-defaults -f /etc/sogo/sogo.conf | awk -F\" '/ OCSFolderInfoURL =/  {print $2}' |  awk -F/ '{print $NF}')
+if [ -f /etc/sogo/sogo.conf ];then
+  indextable=$(sogo-tool dump-defaults -f /etc/sogo/sogo.conf | awk -F\" '/ OCSFolderInfoURL =/  {print $2}' |  awk -F/ '{print $NF}')
+else
+  indextable=$(sogo-tool dump-defaults | awk -F\" '/ OCSFolderInfoURL =/  {print $2}' |  awk -F/ '{print $NF}')
+fi
 if [ -z "$indextable" ]; then
   echo "Couldn't fetch OCSFolderInfoURL value, aborting" >&2
   exit 1
 fi
 
-read -p "Username ($defaultusername): " username
-read -p "Hostname ($defaulthostname): " hostname
-read -p "Database ($defaultdatabase): " database
+read username?"Username ($defaultusername): "
+read hostname?"Hostname ($defaulthostname): "
+read database?"Database ($defaultdatabase): "
 
 if [ -z "$username" ]
 then
@@ -36,7 +40,7 @@ fi
 
 sqlscript=""
 
-function adjustSchema() {
+adjustSchema() {
     oldIFS="$IFS"
     IFS=" "
     part1="`echo -e \"ALTER TABLE $table ALTER COLUMN c_partstates TYPE TEXT;\\n\"`";
